﻿<%@page import="java.net.URLEncoder"%>
<%@page import="com.mysql.jdbc.StringUtils"%>
<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.hhit.collaborative_learning.learning.StoreData"%>
<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	
	String currentPageStr=request.getParameter("currentPage");
	if(StringUtils.isNullOrEmpty(currentPageStr)||currentPageStr.equals("1")){
		Calendar now=Calendar.getInstance();
		String time=Utils.getSomedaysAgo2(now);
		String[] times=time.split(";");
		Utils.personalCurrentTime=times[2];
	}
	String userIdstr=request.getParameter("userId");
	String userNickName=request.getParameter("userNickName");
	PublicDaoImplMySql dao=new PublicDaoImplMySql();
	if(StringUtils.isNullOrEmpty(userIdstr)&&!StringUtils.isNullOrEmpty(userNickName)){
		userNickName=new String(userNickName.getBytes("iso8859-1"),"utf-8");
		userIdstr=dao.getUserIdByUserNickName(userNickName)+"";
	}
	int userId=Integer.parseInt(userIdstr);
	request.setAttribute("blogPage", dao.getBlogByUserId(userId, currentPageStr));
	request.setAttribute("user", dao.getUserInfo(userId));
	HashMap<String, Object> map=StoreData.getUserRankList(userId);
	request.setAttribute("rankMap", map);
	String c_userId=Utils.getCookieValue("userId", request);
	String attent="";
	if(!StringUtils.isNullOrEmpty(c_userId)){
		if(dao.judgeFocus(Integer.parseInt(c_userId), userIdstr)){
			attent+="attented";
		}else{
			attent+="attent";
		}
	}
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
<script src="<%=basePath%>js/plugins.js" type="text/javascript"></script>
<script src="<%=basePath%>js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=basePath%>js/cnick.js"></script>
<script type='text/javascript'>
(function(){
$(function(){
	var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
	var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
	$("body").append(float_ask_img);
	
	var d_top = $('#com-d-top-a');

        $(document).scroll(function(){
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }

        })
        $('#com-d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
});
})();
</script>
<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
	rel="stylesheet" />
<!--new top-->

<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<link rel="Stylesheet" type="text/css"
	href="<%=basePath%>css/style.css" />
<link type="text/css" rel="stylesheet" href="<%=basePath%>css/blue.css" />



</head>
<body>
	<div id="container">
		<div id="header">
			<div class="header">
				<div id="blog_title">
					<h2>
						<a href="http://blog.csdn.net/xiahouzuoxin">${requestScope.user.userNickName
							}</a>
					</h2>
					<h3>一个人的喜欢就是把自己对偶然间闪过的念想坚持，直到它变成一种习惯</h3>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
		</div>

		<div id="navigator">
			<div class="navigator_bg"></div>
		</div>



		<div id="body">
			<div id="main">
				<div class="main">

					<div class="list_item_new">

						<div id="article_toplist" class="list"></div>

						<div id="article_list" class="list">
							<c:forEach items="${requestScope.blogPage.list}" var="blog">
								<div class="list_item article_item">
									<div class="article_title">

										<c:choose>
											<c:when test="${blog.type==1}">
												<span class="ico ico_type_Original"></span>
											</c:when>
											<c:when test="${blog.type==2}">
												<span class="ico ico_type_Repost"></span>
											</c:when>
											<c:when test="${blog.type==3}">
												<span class="ico ico_type_Translated"></span>
											</c:when>
										</c:choose>


										<h1>
											<span class="link_title"><a
												href="<%=basePath %>learning/main_article.jsp?blogId=${blog.blogId}&userId=<%=userId%>"
												target="_self"> <c:if test="${blog.isTop==1 }">
														<font color="red">[置顶]</font>
													</c:if> ${blog.blogName }
											</a></span>
										</h1>
									</div>

									<div class="article_description">${blog.blogDesc}</div>
									<div class="article_manage">
										<span class="link_postdate">${blog.time}</span> <span
											class="link_view" title="阅读次数"><a
											href="<%=basePath %>learning/main_article.jsp?blogId=${blog.blogId}&userId=<%=userId%>"
											target="_self" title="阅读次数">阅读</a>(${blog.readNum })</span> <span
											class="link_comments" title="评论次数"><a
											href="<%=basePath %>learning/main_article.jsp?blogId=${blog.blogId}&userId=<%=userId%>#comments"
											target="_self" title="评论次数">评论</a>(${blog.commentNum
											})</span>

									</div>

									<div class="clear"></div>
								</div>
							</c:forEach>
						</div>

						<!--显示分页-->

						<div id="papelist" class="pagelist">
								<span> ${requestScope.blogPage.count }条数据
									共${requestScope.blogPage.totalPage }页</span>
								<c:if test="${requestScope.blogPage.currentPage>1}">
									<a href="main_personal.jsp?userId=<%=userId%>&currentPage=1">首页</a>
									<a
										href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.currentPage-1}">上一页</a>
								</c:if>
								<c:if test="${requestScope.blogPage.pageDiffer>0}">
									<a
										href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5-4}">...</a>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+1<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+1 }">
											<strong>${requestScope.blogPage.pageDiffer*5+1}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+1}">${requestScope.blogPage.pageDiffer*5+1}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+2<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+2 }">
											<strong>${requestScope.blogPage.pageDiffer*5+2}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+2}">${requestScope.blogPage.pageDiffer*5+2}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+3<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+3 }">
											<strong>${requestScope.blogPage.pageDiffer*5+3}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+3}">${requestScope.blogPage.pageDiffer*5+3}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+4<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+4 }">
											<strong>${requestScope.blogPage.pageDiffer*5+4}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+4}">${requestScope.blogPage.pageDiffer*5+4}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+5<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+5 }">
											<strong>${requestScope.blogPage.pageDiffer*5+5}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+5}">${requestScope.blogPage.pageDiffer*5+5}</a>
										</c:otherwise>
									</c:choose>
								</c:if>
								<c:if
									test="${requestScope.blogPage.totalPage>5 && requestScope.blogPage.pageDiffer<requestScope.blogPage.totalPage/5-1}">
									<a
										href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.pageDiffer*5+6}">...</a>
								</c:if>
								<c:if
									test="${requestScope.blogPage.currentPage<requestScope.blogPage.totalPage}">
									<a
										href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.currentPage+1}">下一页</a>
									<a
										href="main_personal.jsp?userId=<%=userId%>&currentPage=${requestScope.blogPage.totalPage}">尾页</a>
								</c:if>
						</div>

					</div>

					<div class="clear"></div>
				</div>

			</div>
			<div id="side">
				<div class="side">
					<div id="panel_Profile" class="panel">
						<ul class="panel_head">
							<span>个人资料</span>
						</ul>
						<ul class="panel_body profile">
							<div id="blog_userface">
								<a href="<%=basePath %>my.jsp?userId=${requestScope.user.userId}" target="_blank"> <img
									src="<%=basePath %>userIcons/${requestScope.user.userIcon}"
									title="访问我的空间" style="max-width:90%" />
								</a> <br /> <span><a href="<%=basePath %>my.jsp?userId=${requestScope.user.userId}"
									class="user_name" target="_blank">${requestScope.user.userNickName
										}</a></span>
							</div>
							<div class="interact">
								<a href="javascript:void(0);" class="<%=attent %>"
									id="span_add_follow" title="[加关注]"
									onclick="addFocus(<%=userId%>)"></a>

							</div>
							<div id="blog_medal">
								<div class="ico_expert" title="认证专家"
									style="width:54px;height:60px;background:url('<%=basePath%>css/images/bokezhuanjiamiddle.png') no-repeat"></div>
								<div id="bms_box">
									<!-- 									<a target="_blank"> <img -->
									<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/zhuanlandaren.png" -->
									<!-- 										onmouseover="m_over_m(this,2)" onmouseout="m_out_m()" alt="2"> -->
									<!-- 									</a> <a target="_blank"> <img -->
									<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/chizhiyiheng.png" -->
									<!-- 										onmouseover="m_over_m(this,4)" onmouseout="m_out_m()" alt="1"> -->
									<!-- 									</a> -->
								</div>
							</div>
							<ul id="blog_rank">
								<li>访问：<span>${requestScope.user.totalReadNum }次</span></li>
								<li>积分：<span>${requestScope.user.userPoint }</span>
								</li>
								<!-- 								<li>等级： <span -->
								<!-- 									style="position:relative;display:inline-block;z-index:1"> -->
								<!-- 										<img -->
								<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/jianzhang/blog6.png" -->
								<!-- 										alt="" style="vertical-align: middle;" id="leveImg"> -->
								<!-- 										<div id="smallTittle" -->
								<!-- 											style=" position: absolute;  left: -24px;  top: 25px;  text-align: center;  width: 101px;  height: 32px;  background-color: #fff;  line-height: 32px;  border: 2px #DDDDDD solid;  box-shadow: 0px 2px 2px rgba (0,0,0,0.1);  display: none;   z-index: 999;"> -->
								<!-- 											<div -->
								<!-- 												style="left: 42%;  top: -8px;  position: absolute;  width: 0;  height: 0;  border-left: 10px solid transparent;  border-right: 10px solid transparent;  border-bottom: 8px solid #EAEAEA;"></div> -->
								<!-- 											积分：5281 -->
								<!-- 										</div> -->
								<!-- 								</span> -->
								<!-- 								</li> -->
								<li>排名：<span>第${requestScope.user.ranking }名</span></li>
							</ul>
							<ul id="blog_statistics">
								<li>原创：<span>${requestScope.user.originalNum }篇</span></li>
								<li>转载：<span>${requestScope.user.repostNum }篇</span></li>
								<li>译文：<span>${requestScope.user.translatedNum }篇</span></li>
								<li>评论：<span>${requestScope.user.totalCommentNum }条</span></li>
							</ul>
						</ul>
					</div>
		<script type="text/javascript">
		function addFocus(userId){
			var c_userId=$.cookie("userId");
			if(c_userId&&$("#span_add_follow").attr("class")=='attent'){
				$.post("<%=basePath%>AddFocusServlet",{userId:c_userId,a_userId:userId,type:3},function(data,status){
					if(data=='关注成功!'){
						$("#span_add_follow").attr("class","attented");
					}else{
						alert(data);
					}
				});
			}
		}
// 			var username = "xiahouzuoxin";
// 			var _blogger = username;
// 			var blog_address = "http://blog.csdn.net/xiahouzuoxin";
// 			var static_host = "http://static.blog.csdn.net";
// 			var currentUserName = "";
// 			$("#span_add_follow").load("",{},function(){});
// 			window.onload=function(){
// 				var userId=$.cookie("userId");
// 				if(userId){
// 					$.post("<%=basePath%>JudgeFocusServlet",{userId:userId,a_userId:<%=userId%>},function(data,status){
// 						if(data=='true'){
// 							$("#span_add_follow").attr("class","attented");
// 						}else{
// 							$("#span_add_follow").attr("class","attent");
// 						}
// 					});
// 				}
// 			};
		</script>
					
					<div id="hotarticls" class="panel">
						<ul class="panel_head">
							<span> 阅读排行 </span>
						</ul>

						<ul class="panel_body itemlist">
							<c:forEach items="${requestScope.rankMap['readRank'] }"
								var="rank">
								<li><a
									href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>"
									target="_self" title="${rank.blogName }">${rank.blogName }</a><span>(${rank.readNum
										})</span></li>
							</c:forEach>
						</ul>
					</div>

					<div id="hotarticls2" class="panel">
						<ul class="panel_head">
							<span>评论排行</span>
						</ul>
						<ul class="panel_body itemlist">
							<c:forEach items="${requestScope.rankMap['commentRank'] }"
								var="rank">
								<li><a
									href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>"
									target="_self" title="${rank.blogName }">${rank.blogName }</a><span>(${rank.commentNum
										})</span></li>
							</c:forEach>
						</ul>
					</div>
					
					<c:if test="${!empty requestScope.rankMap['recommentList']}">
						<div id="commend" class="panel">
							<ul class="panel_head">
								<span>推荐文章</span>
							</ul>
							<ul class="panel_body itemlist">
								<c:forEach items="${requestScope.rankMap['recommentList'] }"
									var="rank">
									<li><a
										href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>"
										target="_self" title="${rank.blogName }">${rank.blogName }</a></li>
								</c:forEach>
							</ul>
						</div>
					</c:if>

				</div>

				<div class="clear"></div>
			</div>

			<div class="clear"></div>
		</div>
	</div>
</body>
</html>
